package com.hlz.rabbit.mq.wokerqueue;

import com.hlz.rabbit.mq.util.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * 发送线程
 *
 * @author Hongliang Zhu
 * @create 2022-11-20 16:04
 */
public class Task01 {

    public static void main(String[] args) {
        try(Channel channel = RabbitMqUtils.getChannel()){

            channel.queueDeclare("work-queue", false, false, false, null);
            Scanner scanner = new Scanner(System.in);

            while (scanner.hasNext()){
                String message = scanner.nextLine();
                channel.basicPublish("", "work-queue", null, message.getBytes());
                System.out.println("message send success!");
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
